Micron Document
πŸŽ–οΈGitΠ―Ρ€Π°πŸŽ–οΈ


Displaying Rendered β€’ View raw β€’ Download

specs/20260711-153545-message-markdown-styling/contracts/inline-markdown-parser.md bc4e9da3ad7a2a22768cbaecc75810e018bc40e2 (bc4e9da3) Text, 2.16 KB

Contract: Inline Markdown Parser

Location: T383838core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/component/InlineMarkdown.kt
Kind: pure function, no Compose/Android deps, T383838commonTest-covered.
Backing library: T383838org.jetbrains:markdown 0.7.5 (AST).

Signature (illustrative)

T282828
Tff7b72internal Tff7b72fun Td2a8ffparseInlineMarkdownTb4b4b4(Te6edf3sourceTb4b4b4: Tffa657StringTb4b4b4)Tb4b4b4: Te6edf3InlineMarkdownResult


β€’ T383838source β€” the text to parse, AFTER mention substitution (display-space input; see AutoLinkText contract for ordering).
β€’ Returns T383838InlineMarkdownResult(displayText, styleSpans, linkSpans) (see data-model.md).

Behavioral contract

β”Œβ”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ ID β”‚ Given β”‚ Then β”‚
β”œβ”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ P-1 β”‚ T383838a **b** c β”‚ displayText T383838a b c; one T383838StyleSpan(Bold) over T383838b β”‚
β”‚ P-2 β”‚ T383838a *b* c β”‚ italic span over T383838b; single T383838* not treated as bold β”‚
β”‚ P-3 β”‚ T383838a ***b*** c β”‚ bold+italic spans both covering T383838b (overlap allowed) β”‚
β”‚ P-4 β”‚ T383838a ~~b~~ c β”‚ strikethrough span over T383838b β”‚
β”‚ P-5 β”‚ BT383838 a b*cT383838 d β”‚ code span over T383838b*c; the T383838* inside is NOT italic (code p… β”‚
β”‚ P-6 β”‚ T383838LINK0 β”‚ displayText T383838x; T383838LinkSpan(range=x, url=https://e.com) β”‚
β”‚ P-7 β”‚ T383838**oops (unpaired) β”‚ displayText contains literal T383838**oops; no span; no throw… β”‚
β”‚ P-8 β”‚ T383838# headingn- item (block syntax) β”‚ rendered literally as text; no heading/list structure … β”‚
β”‚ P-9 β”‚ T383838line1nline2 β”‚ newline preserved in displayText (FR-007) β”‚
β”‚ P-10 β”‚ empty / blank β”‚ returns empty displayText, empty span lists β”‚
β”‚ P-11 β”‚ emoji-only (caller guards) β”‚ caller skips parser; parser itself still safe if called β”‚
β””β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜


Invariants

β€’ T383838displayText never contains a delimiter that was consumed to produce a span.
β€’ Every T383838StyleSpan.range / T383838LinkSpan.range is within T383838displayText.indices.
β€’ Deterministic: same input β†’ same output (no time/randomness).
β€’ Total: never throws on any T383838String input; malformed markdown degrades to literal text.

Notes

β€’ Strikethrough (T383838~~) requires a GFM-capable flavour or a minimal pre-pass (research R2); either satisfies P-4.
β€’ The parser does not resolve mentions or bare URLs/emails/phones β€” those are layered by T383838AutoLinkText (separation of concerns).

Served by rngit 1.5.3 - Generated in 0.07s